package com.cmict.data.bpm.dal.mysql.definition;

import com.cmict.data.bpm.controller.admin.definition.vo.form.ExternalFormExportReqVO;
import com.cmict.data.bpm.controller.admin.definition.vo.form.ExternalFormPageReqVO;
import com.cmict.data.bpm.dal.dataobject.definition.ExternalFormDO;
import com.cmict.data.framework.common.pojo.PageResult;
import com.cmict.data.framework.mybatis.core.mapper.BaseMapperX;
import com.cmict.data.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 工作流外部表单定义 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ExternalFormMapper extends BaseMapperX<ExternalFormDO> {

    default PageResult<ExternalFormDO> selectPage(ExternalFormPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExternalFormDO>()
                .likeIfPresent(ExternalFormDO::getName, reqVO.getName())
                .eqIfPresent(ExternalFormDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ExternalFormDO::getConf, reqVO.getConf())
                .eqIfPresent(ExternalFormDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ExternalFormDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(ExternalFormDO::getId));
    }

    default List<ExternalFormDO> selectList(ExternalFormExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ExternalFormDO>()
                .likeIfPresent(ExternalFormDO::getName, reqVO.getName())
                .eqIfPresent(ExternalFormDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ExternalFormDO::getConf, reqVO.getConf())
                .eqIfPresent(ExternalFormDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ExternalFormDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(ExternalFormDO::getId));
    }

}
